import { Component, PropTypes } from '@didi/teddy-immutable'
const { func, string, array, bool } = PropTypes

const noop = () => {}
class SelPanelItem extends Component {
  static propTypes = {
    text: string,
    id: string,
    index: string,
    selected: bool,
    items: array,
    originIndex: string,
    onSel: func
  }

  static defaultProps = {
    text: '',
    id: '',
    index: '0',
    originIndex: '0',
    selected: false,
    items: [],
    onSel: noop
  }

  onSel(index, childIndex) {
    if (typeof childIndex !== 'number') {
      childIndex = undefined
    }
    this.props.onSel(index, childIndex)
  }
}

export default SelPanelItem